<template>
	<view>
		<Navbar></Navbar>
		<u-tabs-swiper ref="tabs" active-color="#B3723E" bg-color="transparent" :is-scroll="false" :current="current" :list="tabList" @change="tabChange"></u-tabs-swiper>
		<view class="u-m-20">
			<ActivityList :list="list" :isRecord="true" @goActivityDetial="goActivityDetial"></ActivityList>
		</view>
		<Loadmore :status="status"></Loadmore>
		<view style="height: 200rpx;"></view>
		<Bottom :isReturn="true" @confirm="confirm"></Bottom>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import Bottom from '@/components/Bottom.vue'
	import Loadmore from '@/components/Loadmore.vue'
	import ActivityList from '@/pages/demand/component/ActivityList.vue'
	import reachBottom from '@/mixins/reachBottom.js'
	import { activityList } from '@/network/api.js'
	export default{
		mixins:[reachBottom],
		components:{
			Navbar,
			Bottom,
			ActivityList,
			Loadmore
		},
		data(){
			return{
				current: 0,
				tabList:[{name:'全部'},{name:'待审核'},{name:'待参加'},{name:'已结束'},{name:'已取消'}],
				status: 'loadmore',
				list:[]
			}
		},
		onLoad(){
			this.getActivityList()
		},
		methods:{
			tabChange(val){
				this.current = val
				this.page = 1
				this.list.length = 0
				this.getActivityList()
			},
			getActivityList(){
				const params = {
					user_id: uni.getStorageSync("user_id"),
					type: this.current,
					page: this.page,
					limit: this.pageSize
				}
				activityList(params).then(res=>{
					if(res.data.length > 0){
						res.data.map(item=>{
							this.list.push(item)
						})
					}
					if(res.data.length < 10) this.status = 'nomore'
				})
			},
			goActivityDetial(val) {
				uni.navigateTo({
					url: "/pages/activityDetail/activityDetail?id=" + val.id + '&isBack=true'
				})
			},
			loadData() {
				if(this.status == 'nomore') return
				this.page++
				this.status = 'loading'
				this.getActivityList()
			},
		}
	}
</script>

<style>
</style>